package com.tsx.response.exception;

import com.tsx.response.entity.enums.ReturnCodeEnum;
import lombok.Getter;

@Getter
public class BizException extends RuntimeException {
    private final Integer code;
    private final String message;

    public BizException(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public BizException(Integer code, String message, Throwable cause) {
        super(cause);
        this.code = code;
        this.message = message;
    }

    public BizException(Integer code, Throwable cause) {
        super(cause);
        this.code = code;
        this.message = cause.getMessage();
    }

    public BizException(ReturnCodeEnum returnCodeEnum) {
        super(returnCodeEnum.getMessage());
        this.code = returnCodeEnum.getCode();
        this.message = returnCodeEnum.getMessage();
    }
}
